package com.yiyi.credit.manage.abutment.common.exceptions;


import com.yiyi.credit.manage.abutment.common.enums.ResponseCode;

import java.io.Serializable;


public class ServiceException extends RuntimeException implements Serializable {

    private static final long serialVersionUID = -1695036681341844113L;

    private String errorCode;

    private String errorMsg;

    public ServiceException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public ServiceException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public ServiceException(ResponseCode responseCode) {

        super(responseCode.getMessage());
        this.errorCode = responseCode.getCode();
        this.errorMsg = responseCode.getMessage();
    }

    public ServiceException(ServiceException e) {
        super(e);
        this.errorCode = e.getErrorCode();
        this.errorMsg = e.getMessage();
    }

    public ServiceException(Exception e) {
        super(e);
        this.errorCode = ResponseCode.SERVICE_ERR.getCode();
        this.errorMsg = ResponseCode.SERVICE_ERR.getMessage();
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getMessage() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}
